package com.haoyuchanghong.com;

import com.wiyun.engine.nodes.Director;
import com.wiyun.engine.nodes.Menu;
import com.wiyun.engine.nodes.MenuItemLabel;
import com.wiyun.engine.nodes.Scene;
import com.wiyun.engine.transitions.TransitionScene;

public class LayerGame extends MyLayer {
	public LayerGame(boolean replace) {
        MenuItemLabel item = MenuItemLabel.make("Go Back", this, replace ? "onGoBack" : "onGoBack2");

        Menu menu = Menu.make(item);
        menu.alignItemsVertically();

        addChild(menu);
    }

    public void onGoBack() {
        Scene scene = Scene.make();
        scene.addChild(new LayerFirst(), 0);
        scene.autoRelease(true);
        TransitionScene t = getBackTransition(scene);
        if(t == null)
        	t = getTransition(scene);
        Director.getInstance().replaceScene(t);
    }
    
    public void onGoBack2() {
    	TransitionScene t = getBackTransition(null);
    	if(t == null)
    		t = getTransition(null);
    	Director.getInstance().popSceneWithTransition(t);
    }
}
